From: Matthias Clasen Date: Fri, 18 Nov 2011 03:42:37 +0000 (-0500) Subject: polkit: Find the best user to authenticate as X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~1013^2^2~7292 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=55d6c5ea8f72df17b2928d015644dcd3f31f6b96;p=gnome-shell.git polkit: Find the best user to authenticate as We prefer to ask the user for his own password. If PolicyKit is not configured to accept that, try the root password. If PolicyKit does not accept that either, ask for password of the first user that PolicyKit _will_ accept. The last case is a bit broken, but should rarely occur in real-life configurations. https://bugzilla.gnome.org/show_bug.cgi?id=651547 --- diff --git a/js/ui/polkitAuthenticationAgent.js b/js/ui/polkitAuthenticationAgent.js index 2d7063ae8..6f0103975 100644 --- a/js/ui/polkitAuthenticationAgent.js +++ b/js/ui/polkitAuthenticationAgent.js @@ -27,6 +27,7 @@ const AccountsService = imports.gi.AccountsService; const Clutter = imports.gi.Clutter; const St = imports.gi.St; const Pango = imports.gi.Pango; +const GLib = imports.gi.GLib; const Gio = imports.gi.Gio; const Mainloop = imports.mainloop; const Polkit = imports.gi.Polkit; @@ -88,10 +89,14 @@ AuthenticationDialog.prototype = { if (userNames.length > 1) { log('polkitAuthenticationAgent: Received ' + userNames.length + ' identities that can be used for authentication. Only ' + - 'considering the first one.'); + 'considering one.'); } - let userName = userNames[0]; + let userName = GLib.get_user_name(); + if (userNames.indexOf(userName) < 0) + userName = 'root'; + if (userNames.indexOf(userName) < 0) + userName = userNames[0]; this._user = AccountsService.UserManager.get_default().get_user(userName); let userRealName = this._user.get_real_name()